<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Class: Haml::Template</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Class</strong></td>
          <td class="class-name-in-header">Haml::Template</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../files/vendor/plugins/haml/lib/haml/template_rb.html">
                vendor/plugins/haml/lib/haml/template.rb
                </a>
        <br />
            </td>
        </tr>

        <tr class="top-aligned-row">
            <td><strong>Parent:</strong></td>
            <td>
                Object
            </td>
        </tr>
        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">

    <div id="description">
      <p>
This class interfaces with <a href="../ActionView.html">ActionView</a> to
make <a href="../Haml.html">Haml</a> usable as a Ruby on Rails plugin. It
usually shouldn&#8216;t need to be used by end users. Just in case, though,
here&#8216;s what you might do to <a
href="Template.html#M000041">render</a> <tt>templates/index.haml</tt>:
</p>
<pre>
  ActionView::Base.register_template_handler(&quot;haml&quot;, Haml::Template)
  base = ActionView::Base.new(&quot;templates&quot;)
  base.render(&quot;index&quot;)
</pre>
<p>
Or, if you want to really get into the nitty-gritty:
</p>
<pre>
  base = ActionView::Base.new
  template = Haml::Template.new(base)
  template.render(&quot;templates/index.haml&quot;)
</pre>

    </div>


   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000040">new</a>&nbsp;&nbsp;
      <a href="#M000038">options</a>&nbsp;&nbsp;
      <a href="#M000039">options=</a>&nbsp;&nbsp;
      <a href="#M000041">render</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">





      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Class methods</h3>

      <div id="method-M000040" class="method-detail">
        <a name="M000040"></a>

        <div class="method-heading">
          <a href="#M000040" class="method-signature">
          <span class="method-name">new</span><span class="method-args">(view)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Creates a <a href="Template.html#M000040">new</a> <a
href="Template.html">Haml::Template</a> object that uses <tt>view</tt> to
<a href="Template.html#M000041">render</a> its templates.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000040-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000040-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/haml/lib/haml/template.rb, line 41</span>
41:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">view</span>)
42:       <span class="ruby-ivar">@view</span> = <span class="ruby-identifier">view</span>
43:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000038" class="method-detail">
        <a name="M000038"></a>

        <div class="method-heading">
          <a href="#M000038" class="method-signature">
          <span class="method-name">options</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Gets various <a href="Template.html#M000038">options</a> for <a
href="../Haml.html">Haml</a>. See README for details.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000038-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000038-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/haml/lib/haml/template.rb, line 29</span>
29:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">options</span>
30:         <span class="ruby-ivar">@@options</span>
31:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000039" class="method-detail">
        <a name="M000039"></a>

        <div class="method-heading">
          <a href="#M000039" class="method-signature">
          <span class="method-name">options=</span><span class="method-args">(value)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Sets various <a href="Template.html#M000038">options</a> for <a
href="../Haml.html">Haml</a>. See README for details.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000039-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000039-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/haml/lib/haml/template.rb, line 34</span>
34:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">options=</span>(<span class="ruby-identifier">value</span>)
35:         <span class="ruby-ivar">@@options</span> = <span class="ruby-identifier">value</span>
36:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000041" class="method-detail">
        <a name="M000041"></a>

        <div class="method-heading">
          <a href="#M000041" class="method-signature">
          <span class="method-name">render</span><span class="method-args">(template, local_assigns={})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Renders the file at the location <tt>template</tt>, with
<tt>local_assigns</tt> available as local variables within the template.
Returns the result as a string.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000041-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000041-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/haml/lib/haml/template.rb, line 48</span>
48:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">render</span>(<span class="ruby-identifier">template</span>, <span class="ruby-identifier">local_assigns</span>={})
49:       <span class="ruby-ivar">@view</span>.<span class="ruby-identifier">instance_eval</span> <span class="ruby-keyword kw">do</span>
50:         <span class="ruby-identifier">evaluate_assigns</span>
51:       <span class="ruby-keyword kw">end</span>
52: 
53:       <span class="ruby-identifier">options</span> = <span class="ruby-ivar">@@options</span>.<span class="ruby-identifier">dup</span>
54:       <span class="ruby-identifier">locals</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:locals</span>] <span class="ruby-operator">||</span> {}
55:       <span class="ruby-identifier">locals</span>.<span class="ruby-identifier">merge!</span> <span class="ruby-identifier">local_assigns</span>
56:       <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:locals</span>] = <span class="ruby-identifier">locals</span>
57: 
58:       <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@view</span>.<span class="ruby-identifier">haml_inline</span>
59:         <span class="ruby-identifier">engine</span> = <span class="ruby-constant">Haml</span><span class="ruby-operator">::</span><span class="ruby-constant">Engine</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">template</span>, <span class="ruby-identifier">options</span>)
60:       <span class="ruby-keyword kw">else</span>
61:         <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:filename</span>] <span class="ruby-operator">||=</span> <span class="ruby-identifier">template</span>
62:         <span class="ruby-identifier">engine</span> = <span class="ruby-constant">Haml</span><span class="ruby-operator">::</span><span class="ruby-constant">Engine</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span>(<span class="ruby-identifier">template</span>), <span class="ruby-identifier">options</span>)
63:       <span class="ruby-keyword kw">end</span>
64: 
65:       <span class="ruby-identifier">yield_proc</span> = <span class="ruby-ivar">@view</span>.<span class="ruby-identifier">instance_eval</span> <span class="ruby-keyword kw">do</span>
66:         <span class="ruby-identifier">proc</span> { <span class="ruby-operator">|</span><span class="ruby-operator">*</span><span class="ruby-identifier">name</span><span class="ruby-operator">|</span> <span class="ruby-identifier">instance_variable_get</span>(<span class="ruby-node">&quot;@content_for_#{name.first || 'layout'}&quot;</span>) }
67:       <span class="ruby-keyword kw">end</span>
68: 
69:       <span class="ruby-identifier">engine</span>.<span class="ruby-identifier">to_html</span>(<span class="ruby-ivar">@view</span>) { <span class="ruby-operator">|</span><span class="ruby-operator">*</span><span class="ruby-identifier">args</span><span class="ruby-operator">|</span> <span class="ruby-identifier">yield_proc</span>.<span class="ruby-identifier">call</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>) }
70: 
71:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>